﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using App.Core.Extensions;
using App.Data;

public partial class Pages_Private_PropertyForRentList : BasePage
{
    private const int PAGE_SIZE = 1;

    protected void Page_Load(object sender, EventArgs e)
    {
        BindPageInfo();
        if (!IsPostBack)
        {
            BindPropertyForRentList(1);
        }
    }
    protected void BindPageInfo()
    {
        Page.Title = WebUtil.GetPageTitle(h4Heading.InnerHtml);
    }
    protected void BindPropertyForRentList(int pageNumber)
    {
        int totalRecord = 0;
        UtilityDAO dao = new UtilityDAO();
        DbParameter[] parameters = new[] {new DbParameter("@CustomerID", SessionCache.CurrentUser.CustomerID)};
        DataSet ds = dao.GetPagedData(AppSQL.GET_PROPERTY_FOR_RENT_BY_CUSTOMER, parameters, pageNumber, PAGE_SIZE, out totalRecord);
        ucRentList.DataSource = ds.Tables[0];
        ucRentList.EditLink = "/Pages/Private/PropertyForRentChange.aspx?ID={0}";
        ucRentList.DataBind();

        ///Bind Pager
        ucRentListPager.TotalRecord = totalRecord;
        ucRentListPager.PageSize = PAGE_SIZE;
        ucRentListPager.PageNo = pageNumber;
        ucRentListPager.TotalRecordMessage = "Total {0} Property(s) for Rent Found.";
        ucRentListPager.DataBind();
    }
    protected void ucRentListPager_PageIndexChanged(object sender, PagerEventArgs e)
    {
        BindPropertyForRentList(e.PageIndex);
    }
}